#pragma once

#include "wlroots.hpp"
#include "wayland-glib.h"
#include "utils.h"

class Server
{
public:
    Server();
    ~Server();
    void run(Server* server, const char *startup_cmd);

private:
    void server_quit(Server* server);

private:
    struct wl_display *m_display;
    GMainLoop* m_glib_loop;

    struct wlr_backend *m_backend;
    struct wlr_session *m_session;
    struct wlr_renderer *m_renderer;
    struct wlr_allocator *m_alloc;

    struct wlr_scene *m_scene;
    struct wlr_scene_output_layout *m_scene_layout;

    struct wlr_gamma_control_manager_v1 *m_gamma_control_manager_v1;
    struct wl_listener m_new_output;
    struct Output* m_output;
    struct wlr_output_layout *m_output_layout;
    struct wl_list m_outputs;

    struct Seat* m_seat;

#if 0
    struct wlr_scene_node *layers[NUM_LAYERS];
    struct wlr_renderer *drw;
    struct wlr_allocator *alloc;
    struct wlr_compositor *compositor;

    Xdg_shell *xdg_shell;
    Xdg_decoration *xdg_decoration;

    struct wlr_xdg_activation_v1 *activation;
    struct wl_listener request_activate;

    struct wlr_output_layout *output_layout;
    struct wl_listener layout_change;

    struct wl_list mons;
    Monitor *selmon;
    struct wl_listener new_output;

//    struct wl_list clients; /* tiling order */
//    struct wl_list fstack;  /* focus order */

    struct wlr_idle *idle;
    struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
    struct wl_listener idle_inhibitor_create;

    struct wlr_layer_shell_v1 *layer_shell;
    struct wl_listener new_layer_shell_surface;

    struct wlr_input_inhibit_manager *input_inhibit_mgr;

    Cursor *cursor;
    KeyboardManager *keyboard_manager;

    struct wl_listener new_input;

    Seat *seat;

    struct wlr_output_manager_v1 *output_mgr;
    struct wl_listener output_mgr_apply;
    struct wl_listener output_mgr_test;

    struct wlr_input_method_manager_v2 *input_method_manager;
    struct wlr_text_input_manager_v3 *text_input_manager;
    struct input_method_relay *input_relay;

    unsigned int cursor_mode;
    Client *grabc;
    int grabcx;
    int grabcy;
#endif
} Server;

